package com.jic.member.impl;

import java.lang.Long;
import java.util.List;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.MememberGradeOrderIncrement;
import com.jic.member.mapper.MememberGradeOrderIncrementMapper;
import com.jic.member.service.MememberGradeOrderIncrementService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 会员等级管理-成长值规则-下单-充值赠送递增表
 * @author : 
 * @email : 
 * @since : 2020-04-02 08:00:11
 * @version : v1.0.0
 */
@Service
public class MememberGradeOrderIncrementServiceImpl implements MememberGradeOrderIncrementService{

    @Autowired
    private MememberGradeOrderIncrementMapper mememberGradeOrderIncrementMapper;

    @Override
    public long insert(MememberGradeOrderIncrement mememberGradeOrderIncrement) {
        long flag = mememberGradeOrderIncrementMapper.insert(mememberGradeOrderIncrement);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return mememberGradeOrderIncrementMapper.delete(id);
    }

    @Override
    public long update(MememberGradeOrderIncrement mememberGradeOrderIncrement) {
        return mememberGradeOrderIncrementMapper.update(mememberGradeOrderIncrement);
    }

    @Override
    public MememberGradeOrderIncrement queryByPrimaryKey(Long id){
        return mememberGradeOrderIncrementMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<MememberGradeOrderIncrement> query(MememberGradeOrderIncrement mememberGradeOrderIncrement){
        return mememberGradeOrderIncrementMapper.query(mememberGradeOrderIncrement);
    }

    @Override
    public PageResult<MememberGradeOrderIncrement> queryPage(MememberGradeOrderIncrement mememberGradeOrderIncrement, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<MememberGradeOrderIncrement> list = mememberGradeOrderIncrementMapper.queryPage(startIndex, pageQuery.getLimit(), mememberGradeOrderIncrement);
        long count = mememberGradeOrderIncrementMapper.queryPageCount(mememberGradeOrderIncrement);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}